package com.htpro.controller;
import com.alibaba.fastjson.JSON;
import com.htpro.pojo.User;
import com.htpro.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@CrossOrigin
@RestController
public class UserController {
@Autowired
    private UserService us;
@GetMapping("/login")
    public void login(HttpServletRequest request, HttpServletResponse response){
    String name=request.getParameter("username");
    String pwd=request.getParameter("pwd");
    User user = us.getOneUser(name,pwd);
    String s = JSON.toJSONString(user);
    try {
        response.getWriter().println(s);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
}
